package LC;

public class Lc50 {
    public static double myPow(double x, int n) {
        return n>=0?cal(x,n):1/cal(x,-n);
    }

    private static double cal(double x, int n) {
        if(n==0) return 1.0;
        double y=cal(x,n/2);
        return n%2==0?y*y:y*y*x;
    }

    public static void main(String[] args) {
        System.out.println(myPow(2.0,3));
    }

}
